/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
 */

package com.huawei.rpc.common.prorocol;

/**
 * @Author Lijl
 * @ClassName MessageProtocol
 * @Description 消息协议，定义编组请求、解组请求、编组响应、解组响应规范
 * @Date 2022/2/14 17:26
 * @Version 1.0
 */
public interface MessageProtocol {

    /**
     * @Author lijl
     * @MethodName marshallingRequest
     * @Description 编组请求
     * @Date 13:44 2022/2/15
     * @Version 1.0
     * @param request 请求信息
     * @return: byte[] 请求字节
    **/
    byte[] marshallingRequest(Request request) throws Exception;

    /**
     * @Author lijl
     * @MethodName unmarshallingRequest
     * @Description 解组请求
     * @Date 13:45 2022/2/15
     * @Version 1.0
     * @param data 请求字节
     * @return: com.huawei.rpc.common.prorocol.Request 请求信息
    **/
    Request unmarshallingRequest(byte[] data) throws Exception;

    /**
     * @Author lijl
     * @MethodName marshallingResponse
     * @Description 编组响应
     * @Date 13:46 2022/2/15
     * @Version 1.0
     * @param response 响应信息
     * @return: byte[] 响应字节
    **/
    byte[] marshallingResponse(Response response) throws Exception;

    /**
     * @Author lijl
     * @MethodName unmarshallingResponse
     * @Description 解组响应
     * @Date 13:47 2022/2/15
     * @Version 1.0
     * @param data 响应字节
     * @return: com.huawei.rpc.common.prorocol.Response 响应信息
    **/
    Response unmarshallingResponse(byte[] data) throws Exception;
}
